<?php

namespace app\admin\middleware;

use think\facade\Db;
use think\facade\Request;
use think\facade\Session;
use app\common\Error;

/**
 * Class CheckAdminAuth
 * @package app\admin\middleware
 * 检测 是否登录
 */
class CheckAdminLogin
{
    public function handle($request, \Closure $next)
    {
        if (empty(Session::get('user_id'))) {
            return redirect(url('admin/login/index'));
            // return json(['code' => Error::NOT_LOGGED_CODE, 'message' => Error::PLEASE_LOGIN_FIRST]);
        }

        return $next($request);
    }
}